/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entities;

import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

/**
 *
 * @author TANGQUOCTUAN
 */
@Entity
public class FoodsItem implements Serializable {
     @Id
    Foods food;
    int quantity=1;
    double price=0;


    public void up(){
        quantity++;
    }



    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public FoodsItem() {
    }

    public FoodsItem(Foods food,int quantity,Double price) {
        this.food = food;
        this.quantity=quantity;
        this.price=price;
    }

    public Foods getFood() {
        return food;
    }

    public void setFood(Foods food) {
        this.food = food;
    }

    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }



    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final FoodsItem other = (FoodsItem) obj;
        if (this.food != other.food && (this.food == null || !this.food.equals(other.food))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 97 * hash + (this.food != null ? this.food.hashCode() : 0);
        return hash;
    }

     public boolean same(FoodsItem obj) {
        if (this.food.getFoodID()==obj.getFood().getFoodID()) {
            return true;
        }
        return false;
    }

    @Override
    public String toString() {
        return food.getFoodID() + " - " + quantity;
    }
}
